'=========================================================================
' =========== Paste the lines below into a standard module ===============Written by Nikhil_07n

Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long

Const SC_MONITORPOWER = &HF170&
Const MON_OFF = 2&
Const WM_SYSCOMMAND = &H112


Private Sub procTurnOff()

  SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MON_OFF

End Sub


'Now you can call the above procedure using a command button , say cmdTurnOff

'==============Add this code to the command button=======================

Private Sub cmdTurnOff_Click()

Call procTurnOff

End Sub

'====================End=================================================